home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.esc;
-
- import java.io.File;
- import java.util.Hashtable;
- import java.util.Vector;
-
- class TreeNode {
- public static final int ROOT = 0;
- public static final int NODE = 1;
- protected int type;
- protected ESCDocument.ESCFile file;
- protected String rootName;
- protected Vector children;
- protected Hashtable hChildren;
- protected TreeNode parent;
-
- public TreeNode(ESCDocument.ESCFile var1, TreeNode var2) {
- this.type = 1;
- this.file = new ESCDocument.ESCFile(File.separator, true);
- this.rootName = "XML Console";
- this.initChildren();
- this.file = var1;
- this.type = 1;
- this.parent = var2;
- }
-
- public TreeNode(String var1) {
- this();
- this.setRootName(var1);
- }
-
- public TreeNode() {
- this.type = 1;
- this.file = new ESCDocument.ESCFile(File.separator, true);
- this.rootName = "XML Console";
- this.initChildren();
- this.type = 0;
- this.parent = null;
- }
-
- public TreeNode(TreeNode var1) {
- this.type = 1;
- this.file = new ESCDocument.ESCFile(File.separator, true);
- this.rootName = "XML Console";
- this.initChildren();
- this.file = var1.file;
- this.type = var1.type;
- this.parent = var1.parent;
- }
-
- public TreeNode getParent() {
- return this.parent;
- }
-
- public void setParent(TreeNode var1) {
- this.parent = var1;
- }
-
- public ESCDocument.ESCFile getFile() {
- return this.file;
- }
-
- public int getType() {
- return this.type;
- }
-
- public void setType(int var1) {
- this.type = var1;
- }
-
- public boolean isRoot() {
- return this.type == 0;
- }
-
- public String getAbsolutePath() {
- return this.isRoot() ? "" : this.file.getAbsolutePath();
- }
-
- public String getID() {
- return this.isRoot() ? this.rootName : this.getAbsolutePath();
- }
-
- public boolean containsChild(TreeNode var1) {
- return this.hChildren.contains(var1);
- }
-
- public boolean containsChild(String var1) {
- return this.hChildren.containsKey(var1);
- }
-
- public TreeNode getChild(String var1) {
- return this.hChildren != null && !this.hChildren.isEmpty() ? (TreeNode)this.hChildren.get(var1) : null;
- }
-
- public TreeNode getChild(int var1) {
- return (TreeNode)this.children.elementAt(var1);
- }
-
- public int getChildIndex(TreeNode var1) {
- return this.children.indexOf(var1);
- }
-
- public synchronized boolean addChild(Object var1) {
- if (var1 instanceof TreeNode) {
- if (this.hChildren == null) {
- this.initChildren();
- }
-
- if (!this.hChildren.contains(var1)) {
- this.hChildren.put(((TreeNode)var1).getID(), var1);
- this.children.addElement(var1);
- return true;
- }
- }
-
- return false;
- }
-
- public synchronized void removeChild(Object var1) {
- if (var1 instanceof TreeNode && this.hChildren != null && this.hChildren.contains(var1)) {
- this.hChildren.remove(((TreeNode)var1).getID());
- this.children.removeElement(var1);
- }
-
- }
-
- public void removeAllChildren() {
- if (this.hChildren != null && this.hChildren.size() > 0) {
- this.initChildren();
- }
-
- }
-
- public int getChildCount() {
- return this.hChildren != null ? this.hChildren.size() : 0;
- }
-
- public boolean isLastFromPath() {
- return this.getChildCount() == 0;
- }
-
- protected Object[] getChildren() {
- TreeNode[] var1 = new TreeNode[this.children.size()];
- this.children.copyInto(var1);
- return var1;
- }
-
- public boolean equals(Object var1) {
- return var1 instanceof TreeNode ? ((TreeNode)var1).getID().equals(this.getID()) : false;
- }
-
- public String toString() {
- return this.isRoot() ? this.rootName : this.file.getName();
- }
-
- public String getRootName() {
- return this.rootName;
- }
-
- public void setRootName(String var1) {
- this.rootName = var1;
- }
-
- private void initChildren() {
- this.hChildren = new Hashtable();
- this.children = new Vector(5);
- }
- }
-